package com.youfang.sixthmedia.version;

import android.content.Context;
import android.content.Intent;

public class VersionManager {

	private Context context;
	// 单例
	private static VersionManager instance = new VersionManager();

	public static VersionManager getInstance() {
		return instance;
	}

	private VersionManager() {

	}

	public VersionManager initContext(Context context) {
		this.context = context;
		return instance;

	}

	public void startTask() {

		// 启动版本检测服务
		Intent intent = new Intent(context, VersionService.class);
		intent.putExtra("command", "start");
		this.context.startService(intent);

	}

	public void startDownload() {
		Intent intent = new Intent(context, VersionService.class);
		intent.putExtra("command", "download");
		this.context.startService(intent);

	}

	public void startDownload(String newVersion) {
		Intent intent = new Intent(context, VersionService.class);
		intent.putExtra("command", "download");
		intent.putExtra("newVersion", newVersion);
		this.context.startService(intent);
	}

	public void interruptTask() {
		Intent intent = new Intent(context, VersionService.class);
		intent.putExtra("command", "interrupt");
		this.context.startService(intent);
	}

}
